package com.ohos.carbon.slice.guidelines;

import com.ohos.carbon.ResourceTable;
import com.ohos.carbon.slice.MainAbilitySlice;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Text;

import java.util.Map;

import static com.ohos.carbon.slice.MainAbilitySlice.pf;

public class ShrineActivity extends AbilitySlice {

    public Button back_button3;
    public Text text_title3;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_activity_shrine);
        initView();

        MainAbilitySlice.all = (Map<String, Integer>) pf.getAll();
        if (MainAbilitySlice.all.size() != 0) {
            if (MainAbilitySlice.all.containsKey("Studies/Shrine")) {
                for (Map.Entry<String, Integer> entry : MainAbilitySlice.all.entrySet()) {
                    if (entry.getKey().equals("Studies/Shrine")) {
                        int integer = entry.getValue();
                        integer++;
                        pf.putInt("Studies/Shrine", integer);
                        pf.flushSync();
                    }
                }
            } else {
                pf.putInt("Studies/Shrine", 1);
                pf.flushSync();
            }
        } else {
            pf.putInt("Studies/Shrine", 1);
            pf.flushSync();
        }
    }

    private void initView() {
        back_button3 = (Button) findComponentById(ResourceTable.Id_back_button3);
        text_title3 = (Text) findComponentById(ResourceTable.Id_title_text3);
        text_title3.setText("SHRINE");
//        back_button3.setButtonElement(ElementScatter.getInstance(getContext()).parse(ResourceTable.Graphic_carbon_search));
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
